<?php

defined('BASEPATH') OR exit('No direct script access allowed');


if ( ! function_exists('read_emp_category'))//递归获取数据库分类
{
        function read_emp_category($db,$id){

                $id=$id;
                $db=$db;
                $arr = array();
                $sql="select * from empcate where parent=$id";
                $result=$db->query($sql);
                $arr=array();
                if(!empty($result)){
                        foreach($result->result_array() as $rows)
                        {
                                   $rows['children'] = read_emp_category($db, $rows['id']);
                               $rows['text']=$rows['name'];
                               $arr[] = $rows;

                        }

                          return $arr;
                }
        }

}

if ( ! function_exists('read_pro_category'))//递归获取数据库分类
{
        function read_pro_category($db,$id){

                $id=$id;
                $db=$db;
                $arr = array();
                $sql="select * from point_list where parent=$id";
                $result=$db->query($sql);
                $arr=array();
                if(!empty($result)){
                        foreach($result->result_array() as $rows)
                        {
                                   $rows['children'] = read_pro_category($db, $rows['id']);
                               $rows['text']=$rows['name'];
                               $arr[] = $rows;

                        }

                          return $arr;
                }
        }

}

if ( ! function_exists('readid'))//递归获id号码
{
        function readid($startid,$db,$str){

              $sql="select `id` from depart where parent=$startid";
              $query=$db->query($sql);
              $arr=$query->result_array();
              if(!empty($query)){
                if(!empty($arr)){
                  foreach ($arr as $key => $value) {
                     $str=$str.readid($value['id'],$db,$str).",".$value['id'];
                  }
                 }
               return $str.",".$startid;
              }
              
        }

}





?>